//
//  UIBarButtonItem+Extensions.swift
//  Swift_weiboDemo
//
//  Created by toro宇 on 2017/5/11.
//  Copyright © 2017年 toro宇. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    // 创建 便利构造函数
    convenience init(title: String, fontSize:CGFloat = 16,target: Any?, action: Selector, backImage: Bool = false) {
        
        let customBtn: UIButton = UIButton.yy_Button(title, fontSize: fontSize, normalColor: UIColor.gray, highLightColor: UIColor.orange)
        customBtn.addTarget(target, action: action, for: .touchUpInside)
        
        if backImage {
            let imageName = "navigationbar_back_withtext"
            customBtn.setImage(UIImage(named: imageName), for: .normal)
            customBtn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
            customBtn.sizeToFit()
        }
        // self.init 
        self.init(customView: customBtn)
    }
    
}
